$('#xz').click(function () { 
    window.location.href = `/Product/CreateOrEdit`
})

$('#bc').click(function () { 
    let id = $('[name=id]').val();
    let productname = $('[name=productname]').val();
    let supplier = $('[name=supplier]').val();
    let price = $('[name=price]').val();
    let stock = $('[name=stock]').val();
    let remarks = $('[name=remarks]').val();
    let obj = {
        id,
        productname,
        supplier,
        price,
        stock,
        remarks
    }

    $.post('/Product/Save', obj, function () {
        alert('保存成功！');
        window.location.href = `/Product/Index`
    })
})

$('#qx').click(function () { 
    window.location.href = `/Product/Index`
})



function shanchu(id) {
    let a = "你真的要删除吗？"
    let b = "你取消了删除！"
    if (confirm(a)) {
        window.location.href = `/Product/Delete/${id}`
    }
    else if (confirm(b)) {
    }
}


function bj(id) { 
    window.location.href = `/Product/CreateOrEdit/${id}`
}




$('#xz').click(function () {
    let Keyword = $('[name=k]').val();
    let obj = {
        Keyword
    }
    $.post('/Product/Select', obj, function (res) {
        $('.b1').html('')
        res.forEach(item => {
            let html = `
            <tr class="b2">
            <td>${item.id}</td>
            <td>${item.productName}</td>
            <td>${item.supplier}</td>
            <td>${item.price}</td>
            <td>${item.stock}</td>
            <td>${item.remarks}</td>
            <td>
                <input type="button" class="bj" onclick="bj(${item.id})" value="编辑">
                <input type="button" class="sc" onclick="sc(${item.id})" value="删除">
            </td>
        </tr>
            `
            $('#biao').append(html)
        });
    })
})